<?
ob_start();
session_start();
include("../conf/config.php");
include("../conf/database.php");
include("../conf/tools.php");



$curTime=getIndianDateTime();
$memberId=$_GET["mid"];
$mode=$_GET["mode"]; 
if($mode=="rp") //Remove Photo
{
$arrInfo_mem=Array();
$arrInfo_mem["photo_filename"]='';
update_qry("bkitc_profiles",$arrInfo_mem," registrant_id=".$memberId);
writeLog("Photo Removed for member ".formatMemberCode($memberId)." : by ".$_SESSION["admin_username"]);
exit;

}

foreach($_POST as $key => $value) { $arr_data[$key]=$value;}

$arr_data["gender"]=$arr_data["rbGender"];
if($arr_data["reg_state"]=="Other") $arr_data["reg_state"]=$arr_data["reg_state_other"];
$arr_data["telephone_no"]=$arr_data["telephone_number"];
$arr_data["mobile_no"]=$arr_data["cell_number"];
$arr_data["alternate_email_id"]=$arr_data["alternate_email"];
$arr_data["email_id"]=$arr_data["email_address"];

$arr_data["rec_status"]="1";
$arr_data["reg_type"]=$arr_data["ddlRegType"];
if($arr_data["reg_type"]=="") $arr_data["reg_type"]="2";
if($arr_data["are_you_bk"]==0) $arr_data["aloukik_dob"]='';

if($arr_data["reg_state"]=="Other") $arr_data["reg_state"]=$_POST["reg_country_other"];
if($arr_data["reg_country"]=="Other") $arr_data["reg_country"]=$_POST["reg_country_other"];
if($arr_data["reg_state1"]=="Other") $arr_data["reg_state1"]=$_POST["reg_country_other1"];
if($arr_data["reg_country1"]=="Other") $arr_data["reg_country1"]=$_POST["reg_country_other1"];


if($arr_data["edu_qual"]=="Other") $arr_data["edu_qual"]=$_POST["edu_qual_other"];
if($arr_data["technical_specifications"]=="Other") $arr_data["technical_specifications"]=$_POST["technical_specifications_other"];


foreach($arr_data as $key => $value) { $arr_data[$key]=addslashes($value); 

}

$target_path = "../images/photos/";
$target_path1 = "../data/resumes/";

$actual_path=$target_path . $memberId . "/";
if(!is_dir($target_path)) mkdir($target_path);
if(!is_dir($actual_path)) mkdir($actual_path);





$actual_path1=$target_path1 . $memberId . "/";
if(!is_dir($target_path1)) mkdir($target_path1);
if(!is_dir($actual_path1)) mkdir($actual_path1);


if($memberId>0)
{


	
$target_path = $target_path . basename( $_FILES['file_photo']['name']); 

if(move_uploaded_file($_FILES['file_photo']['tmp_name'],$actual_path.$_FILES['file_photo']['name'])) {

$arr_data["photo_filename"]=$_FILES['file_photo']['name'];
} 


	
$target_path1 = $target_path1 . basename( $_FILES['file_resume']['name']); 

if(move_uploaded_file($_FILES['file_resume']['tmp_name'],$actual_path1.$_FILES['file_resume']['name'])) {
$arr_data["resume_uploaded"]=$curTime;
$arr_data["resume_filename"]=$_FILES['file_resume']['name'];
} 

update_qry("bkitc_profiles",$arr_data,"registrant_id=".$memberId);
qry_data("update bkitc_profiles set last_updated='".$curTime."' where registrant_id=".$memberId);
writeLog("Member ".formatMemberCode($memberId)." updated : by ".$_SESSION["admin_username"]);


}
else
{

	
	$memberId=insert_qry("bkitc_profiles",$arr_data);
	$arr_data1["reg_password"]=generatePassword(formatMemberCode($memberId));
	update_qry("bkitc_profiles",$arr_data1,"registrant_id=".$memberId);
	
	$toEmailId=$arr_data["email_id"];
	if($toEmailId!="") send_member_email($toEmailId,$memberId);

	

	$actual_path=$target_path . $memberId . "/";
	if(!is_dir($target_path)) mkdir($target_path);
	if(!is_dir($actual_path)) mkdir($actual_path);
	
	

	$actual_path1=$target_path1 . $memberId . "/";
	if(!is_dir($target_path1)) mkdir($target_path1);
	if(!is_dir($actual_path1)) mkdir($actual_path1);

	
	
	$target_path = $target_path . basename( $_FILES['file_photo']['name']); 

	$arrInfo=array();
	if(move_uploaded_file($_FILES['file_photo']['tmp_name'],$actual_path.$_FILES['file_photo']['name'])) {

		$arrInfo["photo_filename"]=$_FILES['file_photo']['name'];
		
		update_qry("bkitc_profiles",$arrInfo," registrant_id=".$memberId);

	} 
	
	
	$target_path1 = $target_path1 . basename( $_FILES['file_resume']['name']); 

	$arrInfo=array();
	if(move_uploaded_file($_FILES['file_resume']['tmp_name'],$actual_path1.$_FILES['file_resume']['name'])) {

		$arrInfo["resume_filename"]=$_FILES['file_resume']['name'];
		$arrInfo["resume_uploaded"]=$curTime;
		update_qry("bkitc_profiles",$arrInfo," registrant_id=".$memberId);

	} 

	qry_data("update bkitc_profiles set submission_date='".$curTime."' where registrant_id=".$memberId);

}


$siglist=$_POST["chk"];

setMemberSIG($memberId,$siglist);

header("location:edit_member.php?mode=edit&mid=".$memberId);
?>



